using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIPidSetting : UIReviseElement
{
    public Pid pid;
    public UIChangeValue[] uIChangeValues;
    protected override void Start()
    {
        base.Start();
        uIChangeValues=GetComponentsInChildren<UIChangeValue>();
    }
    public void Submit()
    {
        pid.kp = float.Parse(uIChangeValues[0].field.text);
        pid.ki = float.Parse(uIChangeValues[1].field.text);
        pid.kd = float.Parse(uIChangeValues[2].field.text);
    }
    private void OnEnable()
    {
        try
        {
            uIChangeValues[0].field.text = pid.kp.ToString();
            uIChangeValues[1].field.text = pid.ki.ToString();
            uIChangeValues[2].field.text = pid.kd.ToString();
        }
        catch
        {

        }
        
    }
    private void FixedUpdate()
    {
        uIChangeValues[0].field.text = pid.kp.ToString();
        uIChangeValues[1].field.text = pid.ki.ToString();
        uIChangeValues[2].field.text = pid.kd.ToString();
    }
}
